package com.yssw.model.vo.client;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.yssw.client.domain.ClientUserSignLog;
import lombok.*;
import org.apache.commons.lang3.ObjectUtils;

import java.util.Calendar;
import java.util.Date;
import java.util.List;
import java.util.Locale;

/**
 * @Author KnockingFarmers
 * @Date 2023/3/30 17:15
 * @PackageName:com.yssw.model.client
 * @ClassName: ClientUserSignLog
 * @Description: TODO
 * @Version 1.0
 */
@Data
@AllArgsConstructor
@NoArgsConstructor
@EqualsAndHashCode
@ToString
public class ClientUserSignLogVo  {

    /**
     * 获取用户打卡记录的月份
     */
    @JsonFormat(pattern = "yyyy-MM")
    private Date getMonth;

    /**
     * 打卡记录
     */
    private List<ClientUserSignLog> clientUserSignLogList;

    /**
     * 打卡进度
     */
    private Double progress;


    public Double getProgress() {
        if (clientUserSignLogList.size()>0) {
            int actualMaximum;
            Calendar calendar = Calendar.getInstance(Locale.CHINA);
            calendar.setTime(getMonth);

            actualMaximum= calendar.getActualMaximum(Calendar.DAY_OF_MONTH);
            return Double.valueOf((actualMaximum/clientUserSignLogList.size()*100));
        }
        return null;
    }

}
